<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
		<el-row :gutter="20">
			<el-col :span="12">
          	  <div class="field-text"><label>请求路由：</label>{{}}</div>
          	  <el-input v-model="form.router" ></el-input>
		  	</el-col>
			<el-col :span="6">
          	  <div class="field-text"><label>请求方式：</label>{{}}</div>
          	  <el-input v-model="form.method" ></el-input>
		  	</el-col>
			<el-col :span="6">
          	  <div class="field-text"><label>用户ID：</label>{{}}</div>
          	  <el-input v-model="form.uid" ></el-input>
		  	</el-col>
		  	<el-col :span="24">
          	  <div class="field-text"><label>操作参数：</label></div>
          	  <el-input type="textarea" :rows="5" v-model="form.param" ></el-input>
		  	</el-col>
		  	<el-col :span="24">
				<div class="field-text"><label>日志信息：</label></div>
          	  <el-input type="textarea" :rows="5" v-model="form.message"></el-input>
		  	</el-col>
		</el-row>
		<template #footer>
			<el-button @click="visible=false">关 闭</el-button>
		</template>
	</el-dialog>
</template>

<script>
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				url: process.env.VUE_APP_FILES_URL,
				titleMap: {
					add: '操作详情',
					edit: '操作详情',
					show: '操作详情'
				},
				visible: false,
				isSaveing: false,
				loading: false,
				parentSearch: {},
				//表单数据
				form: {
					id: 0,
					router: '',
					method: '',
					param: '',
					message: '',
					uid: '',
				},
				//验证规则
				rules: {
					name: [
						{required: true, message: '请输入经纪人姓名'}
					],
				}
			}
		},
		mounted() {

		},
		methods: {
			//显示
			open(mode='add', search){
				this.parentSearch = search
				this.mode = mode;
				this.visible = true;
				return this
			},
			//表单提交方法
			submit() {
				this.$refs.dialogForm.validate(async (valid) => {
					if (valid) {
						this.isSaveing = true;
						var res = await this.$API.agent.users.edit.post(this.form);
						this.isSaveing = false;
						if(res.code == 200){
							this.$emit('success', this.mode, this.parentSearch)
							this.visible = false;
							this.$message.success("操作成功")
						}else{
							this.$alert(res.message, "提示", {type: 'error'})
						}
					}
				})
			},
			//表单注入数据
			setData(data) {
				Object.assign(this.form, data)
			}
		}
	}
</script>

<style>
.field-text{padding:5px 10px 5px 0px;}
.field-text label{ color: #303133;}
</style>
